package com.ponhu.ea2.goodsCenter.bms.api.controller;

import com.ponhu.ea2.common.basic.model.PagedResult;
import com.ponhu.ea2.common.basic.model.ResponseBean;
import com.ponhu.ea2.dto.CloudTradeGoodsCheckDto;
import com.ponhu.ea2.dto.CloudTradeGoodsEditDto;
import com.ponhu.ea2.query.CloudTradeGoodsQuery;
import com.ponhu.ea2.service.facade.CloudTradeGoodsManageService;
import com.ponhu.ea2.vo.CloudTradeCheckResultVo;
import com.ponhu.ea2.vo.CloudTradeGoodsDetailV2VO;
import com.ponhu.ea2.vo.CloudTradeGoodsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/goods/cloudTradeMana")
@Api(tags = "云商前端页面接口", value = "CloudTradeManagementController")
public class CloudTradeManagementController {

    @DubboReference(version = "1.0.0", check = false)
    private CloudTradeGoodsManageService cloudTradeGoodsManageService;

    @ApiOperation(value = "分页查询云商商品列表")
    @PostMapping("/getCloudTradeGoodsList")
    public ResponseBean<PagedResult<CloudTradeGoodsVO>> getCloudTradeGoodsList(@RequestBody CloudTradeGoodsQuery cloudTradeGoodsQuery) {
        return ResponseBean.ok(cloudTradeGoodsManageService.getCloudTradeGoodsList(cloudTradeGoodsQuery));
    }

    @ApiOperation(value = "编辑云商商品")
    @PostMapping("/editCloudTradeGoods")
    public ResponseBean<Boolean> editCloudTradeGoods(@Validated @RequestBody CloudTradeGoodsEditDto cloudTradeGoodsEditDto) {
        return ResponseBean.ok(cloudTradeGoodsManageService.editCloudTradeGoods(cloudTradeGoodsEditDto));
    }

    @ApiOperation(value = "根据云商商品ID查询商品详细信息(V2版本)")
    @GetMapping("/getCloudTradeGoodsDetailById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "云商商品ID",
                    dataType = "long", paramType = "query", required = true)
    })
    public ResponseBean<CloudTradeGoodsDetailV2VO> getCloudTradeGoodsDetailByIdV2(@RequestParam @NotNull Long id) {
        return ResponseBean.ok(cloudTradeGoodsManageService.getCloudTradeGoodsDetailByIdV2(id));
    }

    @ApiOperation(value = "审核云商商品信息")
    @PostMapping("/checkCloudTradeGoods")
    public ResponseBean<Boolean> checkCloudTradeGoods(@Validated @RequestBody CloudTradeGoodsCheckDto cloudTradeGoodsCheckDto) {

        return ResponseBean.ok(cloudTradeGoodsManageService.checkCloudTradeGoods(cloudTradeGoodsCheckDto));
    }

}
